package com.xiaoai.httpClientTestService.httpclient.one;

import com.xiaoai.httpClientTestService.httpclient.utils.HttpUtils;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.ParseException;
import org.apache.hc.core5.http.io.entity.EntityUtils;

import java.io.IOException;

/**
 * 连接池
 */
public class HttpclientDemo2 {
    
    public static void main(String[] args) throws IOException, ParseException {


        CloseableHttpClient httpConnection = HttpUtils.getHttpConnection();

        HttpGet httpGet = new HttpGet("http://www.baidu.com");

        CloseableHttpResponse response = httpConnection.execute(httpGet);

        System.out.println("响应码："+response.getCode());
        HttpEntity entity = response.getEntity();
        System.out.println("实体"+ entity);

        String s = EntityUtils.toString(entity);

        System.out.println(s);




    }
    
    
}
